package ArrayListTest;

import java.util.ArrayList;
import java.util.Scanner;

public class Test2 {
    public static void main(String[] args) {
        ArrayList<student> list2 = new ArrayList<>();
        Scanner sc = new Scanner(System.in);
        for(int i = 0 ; i < 4 ; i++){
            student s4 = new student();
            System.out.println("请输入姓名：");
            String name = sc.next();
            System.out.println("请输入年龄");
            int age = sc.nextInt();
            s4.setName(name);
            s4.setAge(age);

            list2.add(s4);
        }
        for(int i = 0 ; i < list2.size();i++){
            student s6 = list2.get(i);
            System.out.println(s6.getName()+", "+s6.getAge());
        }

    }
}
